<template>
  <view class="page">
    <!-- #ifndef MP-WEIXIN-->
    <my-navbar leftText="设置" @leftClick="back"></my-navbar>
    <!-- #endif -->
    <view class="content">
      <view
        class="list flex-btw"
        :class="item.line ? 'line' : ''"
        v-for="item in list"
        :key="item.name"
        @click="navigaTo(item.path)"
      >
        <text class="fonts_26">{{ item.name }}</text>
        <u-icon name="arrow-right" color="#f2f2f2"></u-icon>
      </view>
    </view>
    <view class="button flex-center" @click="logout">退出登录</view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      list: [
        { name: "更改密码", path: "/subpack/user/change/change_password" },
        {
          name: "更换手机",
          path: "/subpack/user/change/change_phone",
          line: true,
        },
        // {name:'发票信息',path:'/subpack/user/invoice'},
        // {name:'意见反馈',path:'/subpack/user/feedback'},
        { name: "关于我们", path: "/subpack/account/treaty?type=2" },
        { name: "服务条款", path: "/subpack/account/treaty?type=3" },
        { name: "售后规则", path: "/subpack/account/treaty?type=4", line: true },
        // {name:'注册协议',path:'/subpack/account/treaty'},
      ],
    };
  },
  onReady() {
    getApp().setTitle();
  },
  methods: {
    find(str, cha, num, replace) {
      var x = str.indexOf(cha);
      for (var i = 0; i < num; i++) {
        x = str.indexOf(cha, x + 1);
      }
      let newstr = str.split("");
      newstr.splice(x, 1, replace);
      newstr = newstr.join("");
      return newstr;
    },
    logout() {
      uni.showModal({
        content: "是否退出登录",
        confirmColor: "#40AE36",
        success: function (res) {
          if (res.confirm) {
            const lastShownDate = uni.getStorageSync("lastDialogShownDate");
            uni.clearStorageSync();
            if(lastShownDate) uni.setStorageSync("lastDialogShownDate", lastShownDate);
            // #ifdef H5
            window.location.href =
              location.origin + location.pathname + "#/pages/tabar/index?isGuide=true";
            // #endif
            // #ifndef H5
            uni.reLaunch({
              url: "/pages/tabar/index",
            });
            // #endif
          }
        },
      });
    },
    navigaTo(path) {
      uni.navigateTo({
        url: path,
      });
    },
    back() {
      // #ifdef H5
      window.history.back(-1);
      // #endif
      // #ifndef H5
      uni.navigateBack();
      // #endif
    },
  },
};
</script>

<style lang="scss" scoped>
.page {
  .content {
    .list {
      height: 66rpx;
      line-height: 66rpx;
      padding: 0 20rpx;
      border-bottom: 1rpx solid #f2f2f2;
      background: #fff;
    }
    .line {
      margin-bottom: 10rpx;
      border-bottom: none !important;
    }
  }
  .button {
    color: #fff;
    font-size: 26rpx;
    width: 566rpx;
    height: 88rpx;
    background: $dgreen;
    box-shadow: 0px 4rpx 13rpx 1px rgba(10, 2, 5, 0.2);
    border-radius: 44rpx;
    position: fixed;
    bottom: 178rpx;
    left: 0;
    right: 0;
    margin: auto;
  }
}
</style>
